#include <iostream>
#include <string>
#include <limits.h>
#include <vector>
using namespace std;

int MaxlenSubstr(string& s1, string& s2)
{
    if(s1.size() > s2.size())
        swap(s1, s2);  // s1是长度较短的那个
    int retlen = INT_MIN;
    
    int slen = s1.size();  //small_len
    int blen = s2.size();  //big_len
    // 记录之前结果的字串长度的数组，供下一次使用
    vector<vector<int>> vv (slen+1, vector<int>(blen+1, 0));  // slen行，blen列的二维，初始化成0
    
    for(int i = 0; i < slen; ++i){
        for(int j = 0; j < blen; ++j){
            if(s1[i] == s2[j]){
                vv[i+1][j+1] = vv[i][j] + 1; 
            }
            if(retlen < vv[i+1][j+1]){
                retlen = vv[i+1][j+1];
            }
        } 
    }
    return retlen;  
}

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    cout << MaxlenSubstr(s1, s2);
    return 0;
}